
#include <iostream>


#include "../l_image/Image.h"
#include "../l_image/FCorrespondance.h"
#include "../l_image/Histogramme.h"
#include "../l_image/Contour.h"
#include "../l_image/FFT.h"
#include "../l_image/Filtre.h"


using namespace std;
//typedef unsigned int uint;

int main(int argc, char *argv[])
{
        int val = 100;
        Image<1> img(200,100);
        Fcorr *correspondance = new Fcorr();
	
cout << "correspondance.InitTranslation " << endl;
        correspondance->InitTranslation(val);
	img.appFoncCorr(*correspondance,0);
	
cout << "correspondance.InitInversion " << endl;	
	correspondance->InitInversion();
	img.appFoncCorr(*correspondance,0);

cout << "correspondance.InitEgalisation " << endl;	
	vector<unsigned int> hC = img.histoCumule(256,0);
	correspondance->InitEgalisation(hC,img.getHauteur()*img.getLargeur());
	img.appFoncCorr(*correspondance,0);

cout << "img.filtreMedian(0) " << endl;	
	img.filtreMedian(0);

cout << "img.kMoyennes(10,2,0) " << endl;	
	img.kMoyennes(10,2,0);

cout << "img.kMoyennes(10,2,1) " << endl;	
	img.kMoyennes(10,2,1);


	vector<unsigned int> tabHistoEtale;
	double sommeTotale = 0;
	for(int i = 0; i < 255;i++) {tabHistoEtale.push_back(i); sommeTotale += i;}
        vector<unsigned int> hcParametre = img.histoCumule(256, tabHistoEtale);


	vector<unsigned int> hcImageDeBase = img.histoCumule(256,0);
	//correspondance->InitSpecification( hcImageDeBase ,hcParametre ); // ERREUR MEMOIRE, je n'ai pas trouvé la cause


cout << "FFT " << endl;
	int diffX = img.getDiffPuissance2(img.getLargeur());
	int diffY = img.getDiffPuissance2(img.getHauteur());

	if(diffX !=0 && diffY != 0)
               img = img.completionPuissance2(img);

	FFT imageF(img,0.1,diffX,diffY);
	tab_cx cF = imageF.calculTFImage();

cout << "calculSpectreAmplitude " << endl;
	img = imageF.calculSpectreAmplitude(cF,0);
cout << "calculSpectrePhase " << endl;
	img = imageF.calculSpectrePhase(cF,0);

cout << "passeBas " << endl;
	Filtre filtre1(passeBas,0.1);
	filtre1.appliquerFiltre(cF);
cout << "passeHaut " << endl;
	Filtre filtre2(passeHaut,0.1);
	filtre2.appliquerFiltre(cF);
cout << "calculInverseTFImage " << endl;
	imageF.setX(cF);
        cF = imageF.calculInverseTFImage();
cout << "calculImage " << endl;
	img = imageF.calculImage(cF);



	delete correspondance;
	
	return 0;
}

